home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / recent / grabur.lha / graburl / GrabURL.txt < prev    next >
Text File  |  1998-01-05  |  18KB  |  649 lines

  1. GrabURL 2.0 - Selective URL fetching utility
  2. Copyright (C) 1996-97 Serge Emond
  3.  
  4. ----------------------------------------------------------------------------
  5.  
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  19.  
  20. ----------------------------------------------------------------------------
  21.  
  22. Table of contents
  23. ~~~~~~~~~~~~~~~~~
  24. 1. This document
  25. 2. Config file
  26. 3. Arguments
  27. 4. Configuration examples
  28. 5. Url Completion
  29. 6. Filenames
  30. 7. One or 2 examples
  31. 8. The Author
  32.  
  33. 1. This document
  34. ~~~~~~~~~~~~~~~~
  35. Many things may be incorrect or missing in this document.  If you really
  36. want accurate informations, read the source code.
  37.  
  38. 2. Config file
  39. ~~~~~~~~~~~~~~
  40. Lines with '#' as the first non-whitespace character are comments.
  41. Arguments to commands can be enclosed by " or ' to contain spaces.
  42.  
  43. 2.1. Global commands
  44.  
  45. 2.1.1 Section
  46.  
  47.   Use:  Section <SectionName>
  48.  
  49.   You need a matching END command for each section.  A section is a part of
  50.   the config file processed by another part of the program.  Right now,
  51.   there are 2 known sections: "http" and "scan".  Each section has it's own
  52.   set of commands and is processed independantly.  There are also "global"
  53.   options that are outside a Section.
  54.  
  55. 2.1.2 End
  56.  
  57.   Use:  End
  58.  
  59.   You need one to mark the end of a section and return to the "global" part.
  60.  
  61. 2.1.3 Include
  62.  
  63.   Use:  Include <filename>
  64.  
  65.   Includes a new config file that is processed exactly the same way the
  66.   actual config is.
  67.  
  68.   Example:  you have multiple config files that share a common part, include
  69.   the common part at the beginning of the specialized config files.
  70.  
  71. 2.1.4 Delay
  72.  
  73.   Use:  Delay <time>
  74.  
  75.   This will make GrabURL pause between each file download to give a break to
  76.   your link and to internet in general.  The argument is in 1/10 of a
  77.   second.
  78.  
  79.   It is highly recommended to use some delay (ie 10 or 20) for downloads
  80.   that might get far in recursion, espetially if you have a fast internet
  81.   connection.  Harassing a host is not nice for them and can get you
  82.   site-banned.  Be nice and share the net!
  83.  
  84.   Default value: 0
  85.  
  86. 2.1.5 EMail
  87.  
  88.   Use: EMail <your email>
  89.  
  90.   This is the email address sent to the remote server for each request.
  91.  
  92.   If you don't specify any EMail keyword, NO email information is sent.
  93.  
  94.   You should send this information so site operators might email you to be
  95.   nicer instead of site ban you if you do something wrong.  It could also
  96.   prevent a GrabURL ban.  (Refusing all connections made with graburl)
  97.  
  98. 2.1.6 SaveRoot
  99.  
  100.   Use:  SaveRoot <root directory>
  101.  
  102.   This tells GrabURL where to save the files.  You can use "." (or . or '.')
  103.   to save in currect directory.  The default value is the current directory.
  104.  
  105. 2.1.7 DirMode
  106.  
  107.   Use:  Dirmode <mode>
  108.  
  109.   This is the mode (protection bits) for the directories created.  See man
  110.   page for mkdir(2) for more information about the modes.  The mode is an
  111.   octal number.  The default value is 700 (octal), which means the
  112.   protections rwx------.  First position is user bits, second is group bits
  113.   and third is others bits.  The number is the sum of this: 1 for execute
  114.   bit (x), 2 for write bit (w) and 4 for read bit (r).  Mode of existing
  115.   directories is NOT modified.
  116.  
  117. 2.1.8 FileMode
  118.  
  119.   Use:  Filemode <mode>
  120.  
  121.   This affects files the same way DirMode affects directories.  The argument
  122.   also have the same meaning.  If a file gets overwriten, then mode WILL be
  123.   modified.  Default is 700 (octal).
  124.  
  125. 2.1.9 Translate
  126.  
  127.   Use:  Translate <from> <to>
  128.  
  129.   This modifies the filename and dir names.  The first character of "from"
  130.   is changed for the first character in "to".  The 2nd char of "from"
  131.   becomes the 2nd char of "to", etc...
  132.  
  133.   "from" and "to" MUST have the same length.
  134.  
  135.   Example:  translate "~%()" "__++"
  136.   If you download http://moo.com/~hey/Puppet(7).html, instead of saving it
  137.   to "moo.com/~hey/Puppet(7).html" in the SaveRoot-directory, it will save
  138.   it to "moo.com/_hey/Puppet+7+.html".
  139.  
  140. 2.1.10 Retry
  141.  
  142.   Use: Retry
  143.  
  144.   When present, GrabURL will retry every URL that failed ONCE to be
  145.   downloaded.  I'm not even sure it is completly implemented. (!)
  146.  
  147. 2.1.11 Scan
  148.  
  149.   Use: Scan
  150.  
  151.   When present, GrabURL will scan all HTML files and add the urls contained
  152.   in them to the download-list.  A file is considered as being HTML if:
  153.    1- The server says it is html
  154.    2- it contains ".htm" in the filename.  (ie "bobo.htmt.jpg" will be
  155.       scanned)
  156.  
  157. 2.1.12 StayInHost
  158.  
  159.   Use: StayInHost
  160.  
  161.   When in config file, GrabURL will only add urls to the list (when a URL is
  162.   flagged SCAN, ie with the SCAN config-command, SCAN command-line option or
  163.   if specified in the workfile) only if the host name of the to-be-added
  164.   urls is the SAME as the host name of the scanned file.
  165.  
  166.   Example:  you scan the result of http://hop.com/.  http://hop.com/2.gif
  167.   WILL be added to the list, but http://www.yahoo.com/ won't.
  168.  
  169. 2.1.13 NonExists
  170.  
  171.   Use: NonExists
  172.  
  173.   No files gets overwritten on the disk.  If the file already exists, the
  174.   url is skipped.
  175.  
  176. 2.1.14 Depth
  177.  
  178.   Use:  Depth <depth>
  179.  
  180.   Each file has a "depth", which is an integer.  If the file is HTML and
  181.   scanned, the depth of each files added to the list from this file will
  182.   have it's depth minus one.  (ie x.html has depth 4 and is scanned, all new
  183.   files will have a depth of 3).
  184.  
  185.   A file with depth 0 will NOT be scanned.
  186.  
  187.   A file with depth -1 will give a depth of -1 to its child and WILL be
  188.   scanned.
  189.  
  190.   The default is -1 (scan all internet)
  191.  
  192. 2.1.15 AddLog
  193.  
  194.   Use: AddLog <filename> [<optional flags>]
  195.  
  196.   This adds a log to which text information will be appended while GrabURL
  197.   runs.
  198.  
  199.   Filename is simply the filename to add information to.  There are 2
  200.   special filenames: stdout and stderr, which will give output to the
  201.   standard output and standard error streams, respectively.
  202.  
  203.   Options are:
  204.    date     add date stamp
  205.    time     add time stamp
  206.    type     add the type of output
  207.    #        all characters from # to EOL are ignored (ie a comment)
  208.  
  209.   For example,
  210.    AddLog "stderr" type
  211.    AddLog "/var/log/GrabURL.log" type date time
  212.   will do 2 things:  send output to /var/log/GrabURL.log like this:
  213.  
  214. > 01/00/98 00:06:49 [1/1] http://localhost/
  215. > 01/00/98 00:06:49 Received 292 bytes in 0 sec
  216.  
  217.   and print this on the screen, via the error stream:
  218.  
  219. > [1/1] http://localhost/
  220. > Received 292 bytes in 0 sec
  221.  
  222.   Types:
  223.    ?  informations
  224.    *  error
  225.    +  Scan stuff (additions to the list)
  226.    >  Action like "Receiving file"
  227.    X  Debug information (not much debug right now, and have to be compiled
  228.       with GU_DEBUG)
  229.  
  230. 2.2  Section HTTP
  231.  
  232. The following options HAS to be enclosed by:
  233.   Section "http"
  234. and
  235.   end
  236.  
  237. 2.2.1 Auth
  238.  
  239.   Use: Auth <realm> <userpw>
  240.  
  241.   This is for password-protected HTTP files.  The only authentication scheme
  242.   implemented is the only official one I know about: "basic" (see rfc1945).
  243.  
  244.   "realm" is a code associed to the protected page(s) to let clients
  245.   (graburl, netscape, ...) know what password to use for that page.  If you
  246.   dont know the realm of a password protected page, simply try to get it,
  247.   GrabURL will tell you what is the realm.
  248.  
  249.   "userpw" has 2 parts:  you user name and your password, separated by a
  250.   semi-colon.  That part is "encrypted" using base64 and send directly to
  251.   the server.  (So anyone that intercepts your request can know your
  252.   password ;)
  253.  
  254.   Example config-file:
  255.    auth flyers 'joe:foo'
  256.    Auth "MoNgOlfier SeX life" james:tkirk
  257.  
  258.    If GrabURL tries to get a protected page and the servers says the realm
  259.    is "flyers", the user name "joe" with password "foo" is used.
  260.    If the realm is "MoNgOlfier SeX life", user/password used are
  261.    james/tkirk.
  262.  
  263.   Try to use the right case for the letters ;)
  264.  
  265.   Can be used more than once.
  266.  
  267. 2.2.2 RequestLine
  268.  
  269.   Use:  RequestLine <line>
  270.  
  271.   This adds the line <line> exactly as you typed it to ALL HTTP requests.
  272.   CR/LF is appended.
  273.  
  274. 2.3 Section SCAN
  275.  
  276. The following commands has to be enclosed between
  277.   Section "scan"
  278. and
  279.   End
  280.  
  281. 2.3.1 Key
  282.  
  283.   Use:  Key <key>
  284.  
  285.   What I call a "key" (keyword) is a word in the HTML language that indicates
  286.   the presence of an URL following.  In an HTML file, it will look like
  287.   this, for a key named "src":
  288.  
  289.     <key key key src ../hop.jpg key key>
  290.     <key key src=../hop.jpg key>
  291.     <key key src="../hop.jpg" key>
  292.     etc...
  293.  
  294.   This will add the relative url ../hop.jpg to the list.
  295.  
  296.   I know 3 keys for now:
  297.  
  298.   SRC which is used for images and frames
  299.   BACKGROUND which is used for... backgrounf image
  300.   HREF which is used to link to other images or HTML pages or email or
  301.        whatever.
  302.  
  303.   I strongly suggest using this in your config file:
  304.  
  305.    key SRC
  306.    key BACKGROUND
  307.    key HREF
  308.  
  309. 2.3.2 Ignore
  310.  
  311.   Use: Ignore <begin> [<end>]
  312.  
  313.   Works a bit like "key".  When the scanner encounters a tag containing
  314.   "begin" in it, it will skip EVERYTHING up to the moment it encounters the
  315.   matching "end" tag.  If end is not specified, the skipping will stop when
  316.   the "begin" tag is encountered again.
  317.  
  318. 2.3.3 Diese
  319.  
  320.   Use:  Diese <search|normal>
  321.  
  322.   A diese "#" (number sign) is means, in the "url language", to search for a
  323.   label in an html file after displaying it.  For example,
  324.     http://hey.com/hop.html  and
  325.     http://hey.com/hop.html#contents
  326.   These urls both points to the SAME file, "http://hey.com/hop.html".  In
  327.   the second one however, your browser (ie netscape) will search for a label
  328.   named "contents" and position the page accordingly.
  329.  
  330.   When "diese search" is used, the part beginning with "#" is stripped from
  331.   the name and it will act NORMALLY, ie the # means to search in the page.
  332.  
  333.   "diese normal" will make the # a normal character and the request for the
  334.   web page will be sent WITH "#".
  335.  
  336.   You should always use "diese search", which is the default, unless you
  337.   have really specific and private use.
  338.  
  339. 2.3.4 Skip
  340.  
  341.   Use:  Skip <regular expression>
  342.  
  343.   This is a regular expression that, if matched, will make the to-be-added
  344.   URL rejected and NOT being added.  You can use as many Skip Reg
  345.   Expressions as you wish, and if a single one of them is matched, the url
  346.   is rejected.
  347.  
  348.   See "Pattern" below for example.
  349.  
  350. 2.3.5 Pattern
  351.  
  352.   Use: Pattern <regular expression>
  353.  
  354.   This is a regular expression that MUST be matched for GrabURL to add an
  355.   URL to the list.  You can use as many as you want and ALL of them will
  356.   have to be matched for an url to be appended to the list.
  357.  
  358.   Example:
  359.    Pattern .jpe*g$
  360.    Skip foo
  361.  
  362.    When an HTML file is scanned, the urls found in it will only be appended
  363.    to the download-list if:
  364.       1) "foo" is NOT in the url name
  365.       2) the url must end with .jpg, .jpeg, .jpeeg, .jpeeeg, ....
  366.  
  367.    ie,
  368.     http://www.pod.ca/andrew.html    rejected
  369.     http://www.foo.org/hey.jpeg      rejected: contains "foo"
  370.     http://www.bar.org/hey.jPeEg     accepted
  371.  
  372. 3. Arguments
  373. ~~~~~~~~~~~~
  374. Arguments are the information you pass to graburl via the command line.
  375.  
  376. ALL the arguments not matching one of the following is considered as an URL
  377. to be added to the download-list.
  378.  
  379. 3.1 Help
  380.  
  381.   Arg:  help
  382.   Syn:  ?, -h, --help
  383.  
  384.   Gives a summary of the commands supported by GrabURL.
  385.  
  386. 3.2 License
  387.  
  388.   Arg:  license
  389.  
  390.   Shows copyright notice and informations about warranty, etc..  (GPL)
  391.  
  392. 3.3 Config
  393.  
  394.   Arg:  Config <config_file>
  395.   Syn:  c <config_file>
  396.  
  397.   Use this config file.   The search order, when that options is not
  398.   specified, if ".graburlrc" in your home directory, then "/etc/graburlrc".
  399.  
  400. 3.4 SaveRoot
  401.  
  402.   Arg: SaveRoot <root_dir>
  403.   Syn: sr <root_dir>
  404.  
  405.   Specifies the root-directory.  See SaveRoot in config file for more infos.
  406.  
  407. 3.5 InFile
  408.  
  409.   Arg: Infile <file>
  410.   Syn: if <file>
  411.  
  412.   Points to a file containing one URL per line.  You can specify multiple
  413.   'infiles'.
  414.  
  415. 3.6 WorkFile
  416.  
  417.   Arg: Worfile <file>
  418.   Syn: wf <file>
  419.  
  420.   Points to a work file in which each url is "saved" with his options and
  421.   status.  When GrabURL READS the file, it can be simply one URL on each
  422.   line, like for the InFile option.  Basically, each line is like this:
  423.  
  424.     <type> <url> [<options>]
  425.  
  426.   Type can be:
  427.     Q    Queued - not processed/downloaded yet
  428.     R    Received - it's on your disk now :)
  429.     F    Failed - will be retried if you specified the RETRY option.
  430.     X    Fatal error - document don't exists, ...
  431.     M    Moved, the server generally gives a new URL and GrabURL will
  432.          automatically add it to the list.
  433.     (else)  Skip that url, do nothing with it.
  434.  
  435.   An exemple of moved url is if you try to get http://hop.com/vip and vip is
  436.   a directory, the server generally responds with a "moved" error and will
  437.   give GrabURL the new location "http://hop.com/vip/".
  438.  
  439.   The URL is the url..  enclosed or not with " or '.
  440.  
  441.   Options are:
  442.    TO=filename
  443.       Filename to save the file to
  444.    D=depth
  445.       depth of this file if not -1.
  446.    RETRY
  447.       retry flag for this url
  448.    NODIRS  or ND
  449.       Do not create sub-directories for this url
  450.    NONEXISTS or NE
  451.       Do not download if a file of that name is on disk
  452.    SCAN
  453.       Scan this file, if HTML, for recursion.
  454.    STAYONHOST
  455.       Same as StayInHost config option
  456.    IFMODIFIED
  457.       Send an IfModified request to server
  458.  
  459. 3.7 SaveTo
  460.  
  461.   Arg: SaveTo <file>
  462.   Syn: st <file>
  463.  
  464.   Saves the url to the given file.  You may not specify a workfile or more
  465.   than one url when you use this option on the command line.
  466.  
  467. 3.8 Retry
  468.  
  469.   Arg:  retry  or noretry
  470.  
  471.   Sets/unsets the RETRY flag.
  472.  
  473. 3.9 Ifmodified
  474.  
  475.   Arg:  IfModified  or NOIfModified
  476.   Syn:  im or noim
  477.  
  478.   Sets/unsets the IfModified flag.  IfModified is a request sent to the
  479.   server telling the date of the file on disk, if we already have it.
  480.  
  481.   If the server supports that option and our file is newer than theirs (ie
  482.   the file haven't been modified), the server tells us it is not modified
  483.   and dont send the file.
  484.  
  485. 3.10 NonExists
  486.  
  487.   Arg: NonExists or NONonExists
  488.   Syn: ne or none
  489.  
  490.   Sets/unsets the NO_EXISTS flag.  If set, with "NonExists" on commant line
  491.   or in config file, files dont get overwritten and url is skipped.
  492.  
  493. 3.11 NoDirs
  494.  
  495.   Arg: NoDirs or NONoDirs
  496.   Syn: nd or nond
  497.  
  498.   Sets/unsets the nodir flag.  See lower about how files are saved to disk.
  499.  
  500. 3.12 SaveHeader
  501.  
  502.   Arg: SaveHeader or NOSaveHeader
  503.   Syn: sh or nosh
  504.  
  505.   See config file.
  506.  
  507. 3.13 Scan
  508.  
  509.   Arg: scan or Recursive
  510.   Syn: r
  511.  
  512.   Scan files for recursive downloads.   Use NOSCAN to turn it off if you
  513.   set it via the config file.
  514.  
  515. 3.13.1 StayInHost
  516.  
  517.   Arg: StayInHost
  518.   Syn: sih
  519.  
  520.   The scanner only adds an url if it has the same hostname then it's parent.
  521.  
  522. 3.13.2 Pattern
  523.  
  524.   Arg: Pattern <regexp>
  525.   Syn: p <regexp>
  526.  
  527.   See config file.  You may have multiple patterns.
  528.  
  529. 3.13.3 SkipPattern
  530.  
  531.   Arg: SkipPattern <regexp>
  532.   Syn: sp <regexp>
  533.  
  534.   See config file.  You may use multiple skip patterns.
  535.  
  536. 3.13.4 Depth
  537.  
  538.   Arg: Depth <depth>
  539.   Syn: d <depth>
  540.  
  541.   See config file.
  542.  
  543. 4. Configuration example
  544. ~~~~~~~~~~~~~~~~~~~~~~~~
  545. ---------- Begins here
  546. # This is a comment!!
  547.  
  548. Translate "~%()" "____"
  549. SaveRoot .
  550.  
  551. FileMode 0700
  552. DirMode 0700
  553.  
  554. Delay 5
  555.  
  556. AddLog "stderr" type
  557. AddLog "GrabURL.log" type date time
  558.  
  559. Section "http"
  560.         # Realm yop, user grey, password moppe
  561.         Auth yop grey:moppe
  562.  
  563.         RequestLine "Accept: */*"
  564. End
  565.  
  566. Section "scan"
  567.         key SRC
  568.         key  BACKGROUND
  569.         key HREF
  570.         ignore BLOCKQUOTE /BLOCKQUOTE
  571.         diese search
  572. EndSection
  573. ----------- EOF
  574.  
  575. 5. Url Completion
  576. ~~~~~~~~~~~~~~~~~
  577. For now, GrabURL only understands HTTP.  Wanted to add FTP but I dont have
  578. the time or the need for it.
  579.  
  580. If you give GrabURL (on the command line, or in workfile or infile) a name,
  581. alone, like "www.yahoo.com", graburl will complete it to
  582. "http://www.yahoo.com/".
  583.  
  584. The scanner will also encounter relative urls in HTML files.  Those urls are
  585. not complete, the refer to a file relative to the actual document.  For
  586. example an url "../imgs/banner.jpg" in the file comming from
  587. "http://hey.com/carlton/index.html" points in reality to the file
  588. "http://hey.com/imgs/banner.jpg".
  589.  
  590. GrabURL understands names beginning with "/", containig "." and/or ".." and
  591. will modify the url accordingly.
  592.  
  593. 6. Filenames
  594. ~~~~~~~~~~~~
  595. Before creating a file, GrabURL will change it's working directory to the
  596. "saveroot" directory.  Then it creates a directory with the name of the host
  597. and cd to it.  Then creates all the sub-directory names in the url and put
  598. the file there.
  599.  
  600. For example, if saveroot is "/tmp", the url http://buz.com/~hey/ho.html will
  601. be saved to /tmp/buz.com/~hey/ho.html.
  602.  
  603. If you have a translation for "~" to "_", it will be saved as
  604. /tmpTbuz.com/_hey/ho.html.
  605.  
  606. If the option "nodirs" is specified, the filename fill be /tmp/ho.html.
  607.  
  608. If an url ends with "/", the filename will be "index.html".
  609.  
  610. 7. One or 2 examples
  611. ~~~~~~~~~~~~~~~~~~~~
  612.  
  613. graburl www.umontreal.ca
  614.  -> will download http://www.umontreal.ca/
  615.  
  616. graburl www.umontreal.ca r sih
  617.  -> Downloads the complete site of Université de Montréal.
  618.  
  619. graburl www.umontreal.ca r p www.umontreal.ca
  620.  -> same as the previous one
  621.  
  622. graburl www.umontreal.ca r p www.umontreal.ca sp .gif$
  623.  -> same as above but don't download files ending with ".gif".
  624.  
  625. graburl www.umontreal.ca r sih wf hey.wf
  626.  - stop the transfert after 2-3 files then type
  627. graburl wf hey.wf
  628.  -> Begins to download recursively as in the 2nd example, user aborts the
  629.     download, then you resume it.
  630.  
  631. 8. How to contact the author
  632. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  633.   email: Serge Emond <greyl@videotron.ca>
  634.          Serge Emond <ei971807@uqac.uquebec.ca>
  635.  
  636.   smail: Serge Emond
  637.          3392 des Anemones
  638.          Jonquiere, Quebec
  639.          Canada, G7S 5V4
  640.  
  641. You can also check the official GrabURL web page:
  642.       http://pages.infinit.net/greyl/graburl/
  643. It doesn't contains much but you can download graburl from there.
  644.  
  645. Please dont write things like this:
  646. "It only downloads the first file and doesn't do recursion, why?"
  647.  
  648. And please have a look at the README.txt file that came with this.
  649.